export class DataBaseConfig {

    database = ""
    driverClass = ""
    userName = ""
    password = ""
    maxPoolSize = 0
    minPoolSize = 0
    jdbcUrl = ""
    initialPoolSize = 0
    requiredPassword = false

    constructor (database = "", driverClass = "", userName = "", password = "", maxPoolSize = 0, minPoolSize = 0, initialPoolSize = 0, requiredPassword = false, jdbcUrl = ""){
        this.database = database
        this.driverClass = driverClass
        this.userName = userName
        this.password = password
        this.maxPoolSize = maxPoolSize
        this.minPoolSize = minPoolSize
        this.initialPoolSize = initialPoolSize
        this.requiredPassword = requiredPassword
        this.jdbcUrl = jdbcUrl
    }

    static isValid(obj){
        let valid = obj.database != null;
        valid &= obj.driverClass != null;
        valid &= obj.userName != null;
        valid &= obj.password != null;
        valid &= obj.maxPoolSize != null;
        valid &= obj.minPoolSize != null;
        valid &= obj.jdbcUrl != null;
        valid &= obj.initialPoolSize != null;
        valid &= obj.requiredPassword != null;

        if (!valid){
            console.log(obj)
          console.error(
            "Object must be contain {database, driverClass, userName, password, maxPoolSize, minPoolSize, jdbcUrl, initialPoolSize, requiredPassword} membres"
          );
        }
        return valid;
    }
}